import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _isNumber from "lodash/isNumber";
import _isBoolean from "lodash/isBoolean";

/**
 * FieldInputNumber.js
 * @date 2018/11/14
 */
import React from 'react';
import { Form, Checkbox, InputNumber } from 'antd';
// import intl from 'utils/intl';
import { attributeNameProp, attributeTypeProp, attributeValueProp } from "../../config";
import DataType from "../../DataType";
var inputComponentStyle = {
  width: '100%'
};

var FieldInputNumber = /*#__PURE__*/function (_React$Component) {
  _inherits(FieldInputNumber, _React$Component);

  var _super = _createSuper(FieldInputNumber);

  function FieldInputNumber() {
    _classCallCheck(this, FieldInputNumber);

    return _super.apply(this, arguments);
  }

  _createClass(FieldInputNumber, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          form = _this$props.form,
          _this$props$propValue = _this$props.propValues,
          propValues = _this$props$propValue === void 0 ? {} : _this$props$propValue;
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Form.Item, {
        key: "allowThousandth"
      }, form.getFieldDecorator('allowThousandth', {
        initialValue: propValues.allowThousandth
      })( /*#__PURE__*/React.createElement(Checkbox, null, "\u5141\u8BB8\u5343\u5206\u4F4D"))), /*#__PURE__*/React.createElement(Form.Item, {
        key: "precision",
        label: "\u6570\u503C\u7CBE\u5EA6"
      }, form.getFieldDecorator('precision', {
        initialValue: propValues.precision
      })( /*#__PURE__*/React.createElement(InputNumber, {
        min: 0,
        precision: 0,
        step: 1,
        style: inputComponentStyle
      }))), /*#__PURE__*/React.createElement(Form.Item, {
        key: "min",
        label: "\u6700\u5C0F\u503C"
      }, form.getFieldDecorator('min', {
        initialValue: propValues.min,
        rules: [// todo 最小值 必须小于 最大值
        {
          type: 'number'
        }]
      })( /*#__PURE__*/React.createElement(InputNumber, {
        style: inputComponentStyle
      }))), /*#__PURE__*/React.createElement(Form.Item, {
        key: "max",
        label: "\u6700\u5927\u503C"
      }, form.getFieldDecorator('max', {
        initialValue: propValues.max,
        rules: [// 最大值 必须小于 最小值
        {
          type: 'number'
        }]
      })( /*#__PURE__*/React.createElement(InputNumber, {
        style: inputComponentStyle
      }))), /*#__PURE__*/React.createElement(Form.Item, {
        key: "step",
        label: "\u6BCF\u6B21\u6539\u53D8\u6B65\u6570\uFF0C\u53EF\u4EE5\u4E3A\u5C0F\u6570"
      }, form.getFieldDecorator('step', {
        initialValue: propValues.step
      })( /*#__PURE__*/React.createElement(InputNumber, {
        style: inputComponentStyle
      }))));
    }
  }]);

  return FieldInputNumber;
}(React.Component);

export { FieldInputNumber as default };
export function getConfigOfPropValues(propValues) {
  var newConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];

  if (_isBoolean(propValues.allowThousandth)) {
    var _newConfig$push;

    newConfig.push((_newConfig$push = {}, _defineProperty(_newConfig$push, attributeNameProp, 'allowThousandth'), _defineProperty(_newConfig$push, attributeValueProp, propValues.allowThousandth), _defineProperty(_newConfig$push, attributeTypeProp, DataType.Boolean), _newConfig$push));
  }

  if (_isNumber(propValues.precision)) {
    var _newConfig$push2;

    newConfig.push((_newConfig$push2 = {}, _defineProperty(_newConfig$push2, attributeNameProp, 'precision'), _defineProperty(_newConfig$push2, attributeValueProp, propValues.precision), _defineProperty(_newConfig$push2, attributeTypeProp, DataType.Number), _newConfig$push2));
  }

  if (_isNumber(propValues.max)) {
    var _newConfig$push3;

    newConfig.push((_newConfig$push3 = {}, _defineProperty(_newConfig$push3, attributeNameProp, 'max'), _defineProperty(_newConfig$push3, attributeValueProp, propValues.max), _defineProperty(_newConfig$push3, attributeTypeProp, DataType.Number), _newConfig$push3));
  }

  if (_isNumber(propValues.min)) {
    var _newConfig$push4;

    newConfig.push((_newConfig$push4 = {}, _defineProperty(_newConfig$push4, attributeNameProp, 'min'), _defineProperty(_newConfig$push4, attributeValueProp, propValues.min), _defineProperty(_newConfig$push4, attributeTypeProp, DataType.Number), _newConfig$push4));
  }

  if (_isNumber(propValues.step)) {
    var _newConfig$push5;

    newConfig.push((_newConfig$push5 = {}, _defineProperty(_newConfig$push5, attributeNameProp, 'step'), _defineProperty(_newConfig$push5, attributeValueProp, propValues.step), _defineProperty(_newConfig$push5, attributeTypeProp, DataType.Number), _newConfig$push5));
  }

  return newConfig;
}
export var lifeUpgrade = [];
FieldInputNumber.getConfigOfPropValues = getConfigOfPropValues;
FieldInputNumber.lifeUpgrade = lifeUpgrade;